export function getItem (key) {
  // 获取本地存储的数据
  const data = localStorage.getItem(key)
  // 进行try cache的判断
  try {
    return JSON.parse(data)
  } catch (e) {
    return data
  }
}

export function setItem (key, value) {
//  value ==> object  String number
//  接收到的数据是对象 ==> JSONstring
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }

  localStorage.setItem(key, value)
}

export const removeItem = name => {
  // 移除本地存储的用户信息
  window.localStorage.removeItem(name)
}
